package huisu.onClass.class02.exer04;

import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {

    private static int maxTeamNum = -1;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] mat = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                mat[i][j] = sc.nextInt();
            }
        }
        LinkedList<LinkedList<Integer>> teams = new LinkedList<>();
        for (int i = 0; i < n; i++) {
            teams.add(new LinkedList<>());
        }
        dfs(0, n, teams, mat);
        System.out.println(maxTeamNum);
    }

    public static void dfs(int curV, int vets, LinkedList<LinkedList<Integer>> teams, int[][] mat) {
        if (curV == vets) {
            int count = 0;
            for (int i = 0; i < teams.size(); i++) {
                count = Math.max(count, teams.get(i).size());
            }
            maxTeamNum = Math.max(maxTeamNum, count);
            return;
        }
        for (int i = 0; i < teams.size(); i++) {
            LinkedList<Integer> curTeam = teams.get(i);
            boolean allConnect = true;
            for (int v : curTeam) {
                if (mat[curV][v] == 0) {
                    allConnect = false;
                    break;
                }
            }
            if (allConnect) {
                curTeam.add(curV);
                dfs(curV + 1, vets, teams, mat);
                curTeam.removeLast();
            }
        }
    }
}
